package cn.enilu.flash.api.controller.mini;

import cn.enilu.flash.api.controller.BaseController;
import cn.enilu.flash.bean.core.BussinessLog;
import cn.enilu.flash.bean.dictmap.CommonDict;
import cn.enilu.flash.bean.dto.mini.GetCustDto;
import cn.enilu.flash.bean.vo.front.Rets;
import cn.enilu.flash.core.log.LogManager;
import cn.enilu.flash.core.log.LogTaskFactory;
import cn.enilu.flash.enums.body.LogClientType;
import cn.enilu.flash.security.JwtUtil;
import cn.enilu.flash.utils.HttpKit;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @Author Spark
 * @Date Created in (2020/04/22 12:19)
 * @Version v1.0
 * @Modify
 **/
@Slf4j
@RestController
@RequestMapping(value = "/mini", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class CustController extends BaseController {

    @PostMapping(value = "getCust")
    public Object getCust(){
        Long custId = JwtUtil.getCustId();
        String custName = JwtUtil.getCustName();
        String custMobile = JwtUtil.getCustMobile();
        Map<String, Object> result = new HashMap<>();
        result.put("custId", custId);
        result.put("custName", custName);
        result.put("custMobile", custMobile);
        LogManager.me().executeLog(LogTaskFactory.bussinessLog(custId, LogClientType.MINI_APP.getCode(), "拉取个人信息", null, null, JSON.toJSONString(result)));
        return Rets.success(result);
    }
}
